import request from '@/utils/request'

export const getChannelAPI = () =>
  request({
    url: '/v1_0/user/channels'
    // 参数已经携带在request里面了，这里不用携带参数
  })

/**
 * 获取所有频道
 * @returns Promise
 */
export const getAllchannelsAPI = () =>
  request({
    url: '/v1_0/channels'
  })

/**
 *
 * @param {Number} target 用户频道id
 * @returns Promise
 */
export const delMyChannelAPI = (target) => {
  return request({
    url: `/v1_0/user/channels/${target}`,
    method: 'DELETE'
  })
}

/**
 *
 * @param {Number} id 频道id
 * @param {Number} seq 添加索引值
 * @return Promise
 */
export const addMyChannelAPI = (id, seq) => {
  request({
    url: '/v1_0/user/channels',
    method: 'PATCH',
    data: {
      channels: [
        {
          id,
          seq
        }
      ]
    }
  })
}
